﻿Imports CommunityToolkit.Mvvm.ComponentModel
Imports CommunityToolkit.Mvvm.Input

Public Class HomePageViewModel : Inherits ObservableObject

    Private _blogItemPageUri As Uri
    Public Property BlogItemPageUri As Uri
        Get
            Return _blogItemPageUri
        End Get
        Set(value As Uri)
            SetProperty(_blogItemPageUri, value)
        End Set
    End Property

    'Private _blog As Blog
    'Public Property Blog As Blog
    '    Get
    '        Return _blog
    '    End Get
    '    Set
    '        SetProperty(_blog, Value)
    '    End Set
    'End Property

    '生成 AsyncRelayCommand
    Public Property PickBlogCommand As RelayCommand = New RelayCommand(AddressOf PickBlogClicked)

    Private Sub PickBlogClicked()
        ''向服务请求一个 Blog
        'Dim response = Await _client.GetAsync(Of Blog)("vdm/api/blog/pickBlog")
        'If response.Code = 200 Then
        '    Blog = response.Data
        '    '携带 Blog 对象使用 Uri 导航到 BlogItem.xaml
        '    BlogItemPageUri = New Uri(String.Format("/VMDWebFrontend;component/View/Component/BlogItem.xaml?blogId={0}", Blog.Id), UriKind.Relative)
        'End If
        If BlogItemPageUri IsNot Nothing Then BlogItemPageUri = Nothing
        BlogItemPageUri = New Uri(String.Format("/VMDWebFrontend;component/View/Component/BlogItem.xaml?Timestamp={0}", DateTime.Now.Ticks.ToString()), UriKind.Relative)

    End Sub

End Class
